package com.student.db;

import androidx.room.TypeConverter;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import java.lang.reflect.Type;
import java.util.List;

public class RoomEntityConvert {

    private  Gson gson;

    public RoomEntityConvert(){
        gson = new Gson();
    }
    @TypeConverter
    public String objectToString(List<String> list){
        return gson.toJson(list);
    }
    @TypeConverter
    public List<String> stringToObject(String json){
        Type type= new TypeToken<List<String>>() {
        }.getType();
        return gson.fromJson(json,type);
    }
}
